package Demo8.yield;

public class MyRunnable implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"次数:"+i);
            if(Thread.currentThread().getName().equals("temp1")){
                System.out.println("礼让");
                Thread.yield();
            }

        }
    }
}
